"""


"""
from rest_framework import viewsets
from rest_framework.response import Response

from goods.models import SpecificationOption, SPUSpecification
from meiduo_admin.my_pagination import MyPageNumberPagination
from meiduo_admin.serializers import good_options_serializer


class GoodOptionsViewSet(viewsets.ModelViewSet):
    queryset = SpecificationOption.objects.all()
    serializer_class = good_options_serializer.GoodOptionSerializer
    pagination_class = MyPageNumberPagination

    def good_specs(self, rquest):

        specs_data = SPUSpecification.objects.all()

        for spec in specs_data:

            spec.name = "%s--%s" % (spec.spu.name, spec.name)

        serializer = good_options_serializer.SPUSpecSerializer(instance=specs_data, many=True)

        return Response(serializer.data)

